package com.itheima.bigdecimal;

import java.math.BigDecimal;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入要运算的第一个数:");
        String s1 = sc.next();
        System.out.println("请输入要运算的第二个数");
        String s2 = sc.next();
        BigDecimal b1 = new BigDecimal(s1);
        BigDecimal b2 = new BigDecimal(s2);
        while (true) {
            System.out.println("请输入要进行的操作运算[1:加法;2:减法;3:乘法;4:除法;5:退出系统]");
            String choice= sc.next();
            switch(choice){
                case "1":
                    BigDecimal add = b1.add(b2);
                    System.out.println("add = " + add);
                    break;
                case "2":
                    BigDecimal subtract = b1.subtract(b2);
                    System.out.println("subtract = " + subtract);
                    break;
                case "3":
                    BigDecimal multiply = b1.multiply(b2);
                    System.out.println("multiply = " + multiply);
                    break;
                case "4":
                    BigDecimal divide = b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP);
                    System.out.println("divide = " + divide);
                    break;
                case "5":
                    System.out.println("感谢使用");
                    return;
                default:
                    System.out.println("输入有误");
            }
        }
    }
}
